.\" -*- nroff -*-
.\" Copyright 2015      Los Alamos National Security, LLC. All rights reserved.
.\" Copyright 2010 Cisco Systems, Inc.  All rights reserved.
.\" Copyright 2007-2008 Sun Microsystems, Inc.
.\" Copyright (c) 1996 Thinking Machines Corporation
.\" $COPYRIGHT$
.TH MPI_Win_allocate 3 "Jun 10, 2020" "4.0.4" "Open MPI"
.SH NAME
\fBMPI_Win_allocate\fP \- One-sided MPI call that allocates memory and
returns a window object for RMA operations.

.SH SYNTAX
.ft R
.SH C Syntax
.nf
#include <mpi.h>
int MPI_Win_allocate (MPI_Aint \fIsize\fP, int \fIdisp_unit\fP, MPI_Info \fIinfo\fP,
                      MPI_Comm \fIcomm\fP, void *\fIbaseptr\fP, MPI_Win *\fIwin\fP)

.fi
.SH INPUT PARAMETERS
.ft R
.TP 1i
size
Size of window in bytes (nonnegative integer).
.TP 1i
disp_unit
Local unit size for displacements, in bytes (positive integer).
.TP 1i
info
Info argument (handle).
.TP 1i
comm
Communicator (handle).

.SH OUTPUT PARAMETERS
.ft R
.TP 1i
baseptr
Initial address of window.
.TP 1i
win
Window object returned by the call (handle).
.TP 1i
IERROR
Fortran only: Error status (integer).

.SH DESCRIPTION
.ft R
\fBMPI_Win_allocate\fP is a collective call executed by all processes
in the group of \fIcomm\fP. On each process, it allocates memory of at
least \fIsize\fP bytes, returns a pointer to it, and returns a window
object that can be used by all processes in \fIcomm\fP to perform RMA
operations. The returned memory consists of \fIsize\fP bytes local to
each process, starting at address \fIbaseptr\fP and is associated with
the window as if the user called \fBMPI_Win_create\fP on existing
memory. The \fIsize\fP argument may be different at each process and
\fIsize\fP = 0 is valid; however, a library might allocate and expose
more memory in order to create a fast, globally symmetric
allocation. The discussion of and rationales for \fBMPI_Alloc_mem\fP and
\fBMPI_Free_mem\fP in MPI-3.1 \[char167] 8.2 also apply to
\fBMPI_Win_allocate\fP; in particular, see the rationale in MPI-3.1
\[char167] 8.2 for an explanation of the type used for \fIbaseptr\fP.
.sp
The displacement unit argument is provided to facilitate address
arithmetic in RMA operations: the target displacement argument of an
RMA operation is scaled by the factor \fIdisp_unit\fP specified by the
target process, at window creation.
.sp
For supported info keys see \fBMPI_Win_create\fI.
.sp

.SH NOTES
Common choices for \fIdisp_unit\fP are 1 (no scaling), and (in C
syntax) \fIsizeof(type)\fP, for a window that consists of an array of
elements of type \fItype\fP. The later choice will allow one to use
array indices in RMA calls, and have those scaled correctly to byte
displacements, even in a heterogeneous environment.
.sp

.SH ERRORS
Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument.
.sp
Before the error value is returned, the current MPI error handler is
called. By default, this error handler aborts the MPI job, except for
I/O function errors. The error handler may be changed with
MPI_Comm_set_errhandler; the predefined error handler
MPI_ERRORS_RETURN may be used to cause error values to be
returned. Note that MPI does not guarantee that an MPI program can
continue past an error.

.SH SEE ALSO
.ft R
.sp
MPI_Alloc_mem
MPI_Free_mem
MPI_Win_create
MPI_Win_allocate_shared
